package com.easy.customer.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easy.common.bean.CustomerContacts;
import com.easy.common.service.ICustomerContactsService;
import com.easy.common.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("contacts")
public class CustomerContactsController {
    @Autowired
    ICustomerContactsService contactsService;
    @PostMapping("/")
    public ResultData insert(@RequestBody CustomerContacts contacts){
        CustomerContacts result=contactsService.insert(contacts);
        return ResultData.success(result);
    }
    @PutMapping("/")
    public ResultData update(@RequestBody CustomerContacts contacts){
        return ResultData.success(contactsService.update(contacts));
    }
    @DeleteMapping("/{id}")
    public ResultData delete(@PathVariable Integer id){
        int result=contactsService.delete(id);
        if(result>=1){
            return ResultData.success();
        }else{
            return ResultData.fail();
        }
    }
}
